$(function () {
    queryUsers();
});

function queryUsers() {
    $.ajax({
        url:"http://localhost:7080/UserServlet.do",
        type:"post",
        data:{
            method:"queryUserList"
        },
        dataType:"json",
        success:function (data) {
            var result = data.data;
            console.log("请求成功"+result);
            console.log("昵称"+result[0].name);
            $("#tbody").empty();
            for (var i=0;i<result.length;i++) {
                var tr = $("#tbody").append("<tr></tr>");
                var name = $("<td height=\"20\" bgcolor=\"#FFFFFF\">" +
                    "<div align=\"center\">"+result[i].name+"</div></td>");
                var state = result[i].state;
                if(state == 1){
                    state = "未冻结";
                }else{
                    state = "冻结";
                }
                var state1 = $("<td height=\"20\" bgcolor=\"#FFFFFF\">" +
                    "<div align=\"center\">"+state+"</div></td>");
                var del = $("<td height=\"20\" bgcolor=\"#FFFFFF\"><div align=\"center\">\n" +
                    "          <input type=\"checkbox\" name=\"id\" value="+result[i].id+"></div></td>");
                var find = $("<td height=\"20\" bgcolor=\"#FFFFFF\"><div align=\"center\"><a" +
                    " href=\"lookUserinfo.html?id="+result[i].id+"\"><img src=\"images/button_select.png\"" +
                " width=\"14\" height=\"13\" border=\"0\"></a></div></td>");
                tr.append(name).append(state1).append(del).append(find);
            }
        },
        error:function (result) {
            alert("请求失败"+result);
        }
    });
}